﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace mbine.msgc.model
{
    /// <summary>
    /// 현재 접속한 사용자
    /// </summary>
    public sealed class CCUser : CUser
    {
        static CCUser instance = null;
        static readonly object padlock = new object();

        CCUser()
        {
        }

        public static CCUser Instance
        {
            get
            {
                lock (padlock)
                {
                    if (instance == null)
                    {
                        instance = new CCUser();
                    }
                    return instance;
                }
            }
        }

        public void Login()
        {
            this.IsLogin = true;
            this.Status = new CStatus(1, "Online");
        }

        public void Logout()
        {
            this.IsLogin = false;
            this.Status = new CStatus(5, "Offline");
        }

        public void StatusChange(CStatus _status)
        {
            this.Status = _status;
        }

        public void ChangeInfo(CCUser _newuser)
        {
            this.Name = (_newuser.Name != null) ? _newuser.Name : null;
            this.Avatar = (_newuser.Avatar != null) ? _newuser.Avatar : null;
            this.Email = (_newuser.Email != null) ? _newuser.Email : null;
            this.Password = (_newuser.Password != null) ? _newuser.Password : null;
        }
    }
}
